<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      border
      :tree-props="{children: 'children'}"
    >
      <el-table-column prop="id" label="编号" align="center"></el-table-column>
      <el-table-column prop="title" label="轮播图标题" align="center"></el-table-column>
      <el-table-column  label="图片" align="center">
        <template slot-scope="scope">
          <img :src="$pre+scope.row.img" alt="">
        </template>
      </el-table-column>

      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status==1">启用</el-button>
          <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="primary"  @click="willEdit(scope.row.id)">编辑</el-button>
          <del-btn @del="del(scope.row.id)"></del-btn>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { successAlert } from "../../../utils/alert";
import { mapGetters, mapActions, } from "vuex";
import {reqbannerdelete} from "../../../request/api"
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters({
      list: "banner/list",
    }),
  },
  methods: {
    ...mapActions({
      reqlist: "banner/reqlist",
    }),
    del(id){
      reqbannerdelete({id:id}).then(res=>{
        if (res.data.code == 200) {
          successAlert(res.data.msg);
          this.reqlist()
        }
        // console.log(res);
      })
    },
     willEdit(id) {
      this.$emit("edit", id);
    },
  },
  mounted() {
    this.reqlist();
  },
};
</script>
<style scoped>
img{
  width: 250px;
  height: 100px;

}
</style>